//兑换码验证
exports.exchange_course_validate = function (req, res) {

    var restfulParams = req.routeInfo.restfulParams;
    //最终结果
    var resultData = {};
    var is_exist = 0;
    //任务流创建
    async.waterfall([
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.userExchangeCoupon +"/uec_is_used/0/uec_exchange_code/"+restfulParams.exchange_code+"/o_id/"+restfulParams.oid,
                        method: 'POST',
                        data: {
                            fields: ["uec_id","ec_name","ec_desc","u_header_url"].join(",")
                        }
                    },
                    function (err, data) {
                        //判断是否有错误信息
                        // if (err) {
                        //     return cb(err, data);
                        // }
                        console.log(123);
                        console.log(data.data);
                        is_exist = data.data;
                        cb();
                    }
                );
            },
            function (cb) {
                if(is_exist.length == 0){
                    resultData = "兑换码不存在或已使用";
                    return RES.response(res,false, resultData);
                }else{
                    resultData.exchangeData = is_exist;
                    cb();

                }

            }
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}